﻿/************************************************************************************
* Copyright (c) 2019 All Rights Reserved.
*命名空间：Merge.BLL
*文件名： EffectiveClassGudge
*创建人： Liebeskind
*创建时间：2019/7/2 17:04:41
*描述
*=====================================================================
*修改标记
*修改时间：2019/7/2 17:04:41
*修改人：Liebeskind
*描述：
************************************************************************************/
using System;
using System.Collections.Generic;
using static Commonality.DAL.MySQL.MySqlFunction;

namespace Merge.BLL
{
    /// <summary>
    /// 淘汰数据库中逐渐陈旧与量少的类型
    /// </summary>
    internal partial class EffectiveClassGudge
    {
        /// <summary>
        /// 设置衰竭时间长度
        /// </summary>
        public static double AdvancedAge { get; set; }
        /// <summary>
        /// 设置大批量阈值
        /// </summary>
        public static int LargeNumber { get; set; }


        public static void EffectiveClassGudgeInit()
        {
            AdvancedAge = 10;
            LargeNumber = 240;
            GudgeAction = GudgeFunction;
        }

        /// <summary>
        /// 执行方法
        /// 注意避免阻塞
        /// </summary>
        public static string GudgeFunction()
        {
            List<string> PnList = new List<string>();
            int pro = 0;
            AttentionPnData.AttentionPnData_SELECT(ref PnList);
            foreach (string item in PnList)
            {
                AttentionPnData.AttentionPnData_Project_SELECT(item, ref pro);
                if (pro < LargeNumber)
                {
                    AttentionPnData.AttentionPnData_Pn_DELETE(item);                //删除尾数
                    return item;
                }
            }
            return "";
        }
        /// <summary>
        /// 
        /// </summary>
        public static Func<string> GudgeAction;

    }
}
